home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 12666 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: news.iadfw.net!usenet
  2. From: Mark Nelson <markn@airmail.net>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Dynamically allocated interrupt handlers?
  5. Date: Wed, 20 Mar 1996 21:08:37 -0600
  6. Organization: customer of Internet America
  7. Message-ID: <3150C835.3433@airmail.net>
  8. References: <4iqbv5$mqd@lori.albany.net>
  9. NNTP-Posting-Host: dal17-30.ppp.iadfw.net
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0GoldB1 (Win95; I)
  14.  
  15. Stephen Behnfeldt wrote:
  16. > I am building a SerialPort class to model the serial ports on my PC.
  17. > Associated with each instance of this class are elements such as an
  18. > input character buffer and a hardware address - data members which
  19. > will be unique to each instance.
  20.  
  21. > So it seems like each handler will have to be
  22. > distinct - one for each instance of the class.
  23.  
  24. You can minimize this pretty easily.  Instead of having N interrupt handlers, 
  25. you just code N different entry points. The entry points looks something like
  26. this:
  27.  
  28. _interrupt isr0()
  29. {
  30.    handler(0);
  31. }
  32.  
  33. _interrupt isr1()
  34. {
  35.     handler(1);
  36. }
  37.  
  38. ...
  39.  
  40. Then, your handler routine simply uses the number as an index into a
  41. table of pointers.  The table has pointers to C++ objects, which then
  42. means you are back in object oriented land, where you belong.
  43.  
  44. I cover this in some detail in my book "Serial Communications: A C++
  45. Developer's Guide."  For more information on the book, follow the
  46. links on my home page.
  47.  
  48. Mark Nelson
  49. http://web2.airmail.net/markn
  50.